#include <iostream>
#include "Heap.h"
#include "SimpleClass.h"
#include "Tree.h"
#include "AvlTree.h"
#include "math.h"
#include <cstdlib>

using namespace std;

void a1()
{
	cout << "************************ Aufgabe 1.1 ***********************\n";
	Heap<double> heap(100);
	heap.push(10);
	heap.push(13);
	heap.push(2);

	heap.pop();

	heap.push(5);
	heap.print();

	Heap<SimpleClass> simpleHeap(100);
	simpleHeap.push(SimpleClass(9));
	simpleHeap.push(SimpleClass(18));
	simpleHeap.push(SimpleClass(2));

	simpleHeap.pop();

	simpleHeap.push(SimpleClass(12));

	simpleHeap.print();
}

void a2()
{
	cout << "\n\n\n************************ Aufgabe 1.2 ***********************\n";

	int size = 100;
	int *arr = new int[size];
	Heap<int> heap(size);

	for(int i=0; i<size; i++)
	{
		int random = rand() % size;
		cout << '[' << i << "] = " << random << '\n';
		arr[i] = random;
		heap.push(random);
	}

	cout << "\n\n\n\n------------sorted-------------\n";

	for(int i=size - 1; i>=0; i--)
	{
		arr[i] = heap.pop();
	}

	for(int i=0; i<size; i++)
	{
		cout << '[' << i << "] = " << arr[i] << '\n';
	}

}

void a3()
{
	cout << "\n\n\n************************ Aufgabe 1.3 ***********************\n";

	int cycles = 3;
	int size = 10000;
	for(int i=0; i<cycles; i++)
	{
		int currentSize = size * (i+1);

		Tree tree;
		AvlTree avlTree;

		for(int l=0; l<currentSize; l++)
		{
			int random = rand() % currentSize;
			tree.insert(random);
			avlTree.insert(random);
		}

		cout << "\n********************* n = " << currentSize << " ********************************\n";

		cout << "Tree Height: " << tree.height() << '\n';
		int height = avlTree.height();
		cout << "AvlTree Height: " << height << '\n';
		
	}
}

int main()
{
	a1();

	a2();

	a3();

	int a;
	cin >> a;
	return 0;
}

